package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Region extends BaseDomain {
    public static final Integer STATE_RECOMMEND = 1;
    public  static final  Integer STATE_NORMAL = 0;
    public  static final  Integer STATE_SHIELD = -1;

    private String name;

    private Integer state = STATE_NORMAL;

    private Region parent;

    public Map getMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("text",name);
        map.put("lazyLoad",true);
        map.put("id",getId());
        if(state == STATE_RECOMMEND){
            map.put("tags",new String[]{"推荐"});
        }
        return map;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("name",name);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }

    public String getStateName(){
        String temp = "取消推荐";
        if (state == null || state == Region.STATE_NORMAL) {
            temp = "设置推荐";
        }
        return temp;
    }

}